package bold.storage.core;


import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;

public class Page extends HashMap {
    /**
     * @param currPage  开始页
     * @param pageSize  数量
     * @param totalPage 总页数
     * @param totalRow  总条数
     */
    public Page(RecordList list, int currPage, int pageSize, int totalPage, int totalRow) {
        super.put("list", list);
        super.put("pageIndex", currPage);
        super.put("pageSize", pageSize);
        super.put("totalPage", totalPage);
        super.put("totalRow", totalRow);
    }

    public RecordList getList() {
        return (RecordList) super.get("list");
    }

    public int getCurrPage() {
        return ((Integer) super.get("currPage")).intValue();
    }

    public int getPageSize() {
        return ((Integer) super.get("pageSize")).intValue();
    }

    public int getTotalPage() {
        return ((Integer) super.get("totalPage")).intValue();
    }

    public int getTotalRow() {
        return ((Integer) super.get("totalRow")).intValue();
    }

    public JSONObject toJSONObject() {
        JSONObject json = new JSONObject();
        json.put("list", super.get("list"));
        json.put("currPage", super.get("currPage"));
        json.put("pageSize", super.get("pageSize"));
        json.put("totalPage", super.get("totalPage"));
        json.put("totalRow", super.get("totalRow"));
        return json;
    }
}